/* FPU Restore Functions */
/*******************************/
/* Restore x87 extended state */
-static inline void fpu_xrstor(struct vcpu *v)
+static inline void fpu_xrstor(struct vcpu *v, uint64_t mask)
{
/*
* XCR0 normally represents what guest OS set. In case of Xen itself,
* we set all supported feature mask before doing save/restore.
*/
set_xcr0(v->arch.xcr0_accum);
- xrstor(v);
+ xrstor(v, mask);
set_xcr0(v->arch.xcr0);
}
/* FPU Save Functions */
/*******************************/
/* Save x87 extended state */
-static inline void fpu_xsave(struct vcpu *v)
+static inline void fpu_xsave(struct vcpu *v, uint64_t mask)
{
/* XCR0 normally represents what guest OS set. In case of Xen itself,
* we set all accumulated feature mask before doing save/restore.
*/
set_xcr0(v->arch.xcr0_accum);
- xsave(v);
+ xsave(v, mask);
set_xcr0(v->arch.xcr0);
}
return;
if ( xsave_enabled(v) )
- fpu_xrstor(v);
+ fpu_xrstor(v, XSTATE_ALL);
else if ( v->fpu_initialised )
{
if ( cpu_has_fxsr )
clts();
if ( xsave_enabled(v) )
- fpu_xsave(v);
+ fpu_xsave(v, XSTATE_ALL);
else if ( cpu_has_fxsr )
fpu_fxsave(v);
else
return this_cpu(xcr0);
}
-void xsave(struct vcpu *v)
+void xsave(struct vcpu *v, uint64_t mask)
{
struct xsave_struct *ptr = v->arch.xsave_area;
+ uint32_t hmask = mask >> 32;
+ uint32_t lmask = mask;
if ( cpu_has_xsaveopt )
asm volatile (
".byte " REX_PREFIX "0x0f,0xae,0x37"
:
- : "a" (-1), "d" (-1), "D"(ptr)
+ : "a" (lmask), "d" (hmask), "D"(ptr)
: "memory" );
else
asm volatile (
".byte " REX_PREFIX "0x0f,0xae,0x27"
:
- : "a" (-1), "d" (-1), "D"(ptr)
+ : "a" (lmask), "d" (hmask), "D"(ptr)
: "memory" );
}
-void xrstor(struct vcpu *v)
+void xrstor(struct vcpu *v, uint64_t mask)
{
+ uint32_t hmask = mask >> 32;
+ uint32_t lmask = mask;
+
struct xsave_struct *ptr = v->arch.xsave_area;
asm volatile (
".byte " REX_PREFIX "0x0f,0xae,0x2f"
:
- : "m" (*ptr), "a" (-1), "d" (-1), "D"(ptr) );
+ : "m" (*ptr), "a" (lmask), "d" (hmask), "D"(ptr) );
}
bool_t xsave_enabled(const struct vcpu *v)
#define XSTATE_FP_SSE (XSTATE_FP | XSTATE_SSE)
#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP)
+#define XSTATE_ALL (~0)
+#define XSTATE_NONLAZY (XSTATE_LWP)
+#define XSTATE_LAZY (XSTATE_ALL & ~XSTATE_NONLAZY)
+
#ifdef CONFIG_X86_64
#define REX_PREFIX "0x48, "
#else
/* extended state operations */
void set_xcr0(u64 xfeatures);
uint64_t get_xcr0(void);
-void xsave(struct vcpu *v);
-void xrstor(struct vcpu *v);
+void xsave(struct vcpu *v, uint64_t mask);
+void xrstor(struct vcpu *v, uint64_t mask);
bool_t xsave_enabled(const struct vcpu *v);
/* extended state init and cleanup functions */